package com.cy.pj.sys.servicelmpl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cy.pj.common.exception.ServiceException;
import com.cy.pj.sys.dao.SysMenuDao;
import com.cy.pj.sys.dao.SysRoleMenuDao;
import com.cy.pj.sys.service.SysMenuService;

@Service
public class SysMenuServiceImpl implements SysMenuService {
	@Autowired
	private SysMenuDao sysMenuDao;
	private SysMenu
	@Override
	public int delectObject(Integer id) {
		//1参数
		if(id==null||id<1)
			throw new IllegalAccessException("id无效");
		//2基于id系统子菜单
		int childCount=sysMenuDao.getChildCount(id);
		if(childCount>0)
			throw new ServiceException("请先删除菜单");
		//3删除菜单角色关系数据
		SysRoleMenuDao.delecteObjectsByMenuId(id);
		
		return 0;
	}
	
	@Autowired 
	public SysMenuServiceImpl SysMenuDao;
	@Override
	public List<Map<String, Object>> findObjects() {
		List<Map<String,Object>> list=
				SysMenuDao.findObjects();
		if(list==null||list.size()==0)
			throw new ServiceException("没有对应的菜单信息");
		return null;
	}
	

}
